<template>
  <div>
    <div
      v-if="data?.length >= 1"
      @click="handleLink(data[0]?.oss_path)"
      class="cursor-pointer text-[#3486fe]"
    >
      {{ data[0]?.source_name }}
    </div>
    <div
      v-if="data?.length === 2"
      class="cursor-pointer text-[#3486fe] mt-[2px]"
      @click="open(data)"
    >
      更多信息
    </div>
  </div>
</template>
<script setup lang="jsx">
import { ElMessageBox } from "element-plus";
import { handleLink } from "@/hooks/tool.js";
const props = defineProps({
  data: { type: Array, default: () => [] },
  title: { type: String, default: "测试" },
});
const { data, title } = toRefs(props);
const open = (data) => {
  const obj = data
    .map(
      (item) => `
        <div 
          class="cursor-pointer text-[#3486fe] mt-[2px]" 
          onclick="window.open('${item.oss_path}', 'noopener', 'noreferrer')"
        >
          ${item.source_name}
        </div>`
    )
    .join("");
  ElMessageBox.alert(obj, title.value, {
    dangerouslyUseHTMLString: true,
  });
};
</script>
<style lang="scss" scoped></style>
